import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

let str = localStorage.getItem('mytodoList') || "[]";
let list = JSON.parse(str)

export default  new Vuex.Store({
  state:{
    todoList:list
  },
  mutations:{
    add(state,option){
      state.todoList.push(option)
      localStorage.setItem('mytodoList',JSON.stringify(state.todoList))
    },
    remove(state,option){
      state.todoList.splice(option,1)
      localStorage.setItem('mytodoList',JSON.stringify(state.todoList))
    }
  }
}) 